import React from "react";
import BaseComponent from "../../redare/components/BaseComponent";

/**
 * 带有颜色的字体状态组件
 * @date 2020-8-20 16:15:42
 * @author WanJie.Peng
 */
export default class TextStatus extends BaseComponent{

  static defaultProps = {
    color: '',
    status: '' // success | processing | default | error | warning
  };

  constructor(props) {
    super(props);

    let _color = '';
    let {color, status} = this.props;
    if( status ){
      switch (status){
        case 'success':
          _color = '#87d068';
          break;
        case 'processing':
          _color = '#108ee9';
          break;
        case 'default':
          _color = '#ccc';
          break;
        case 'error':
          _color = 'red';
          break;
        case 'warning':
          _color = 'orange';
          break;
      }
    }
    if( color ){
        _color = color;
    }

    this.state = {color: _color};
  }


  render() {
    return <span style={{color: this.state.color}}>{this.props.children}</span>
  }

}